//
// Created by wkm on 2024-04-17.
//

#ifndef AES128CHIPSYSTEMC_XDTIME_H
#define AES128CHIPSYSTEMC_XDTIME_H

#include "x2time.h"

SC_MODULE(xDtime) {
    sc_in<bool> reset, start, clk;
    sc_in<sc_uint<DATA_SIZE>> input_data;

    sc_out<sc_uint<DATA_SIZE>> result;
    sc_out<exe_state> done;

    exe_state next_done;
    sc_uint<DATA_SIZE> next_result;
    sc_uint<2> is_two; // 要算两次，用来标记是否已经算了2从 D=8+4+1

    sc_signal<sc_uint<DATA_SIZE>> x2_input_data, x2_compute_times, x2_result;
    sc_signal<bool> x2_start, x2_reset;
    sc_signal<exe_state> x2_done;

    x2time *x2;

    void prc_xDtime();

    SC_CTOR(xDtime) {
        x2 = new x2time("x2time_of_xDtime");

        x2->clk(clk);
        x2->start(x2_start);
        x2->reset(x2_reset);
        x2->input_data(x2_input_data);
        x2->compute_times(x2_compute_times);
        x2->result(x2_result);
        x2->done(x2_done);

        SC_METHOD(prc_xDtime);
        sensitive << clk.pos();
    }

    ~xDtime() {
        delete x2;
    }
};

#endif //AES128CHIPSYSTEMC_XDTIME_H
